library("doRedis")

registerDoRedis("jobs")
set.seed(1)
A <- matrix(rnorm(100), nrow=10)
A1 <- A[1:5,]
A2 <- A[6:10,]
redisSet("A1", A1)
redisSet("A2", A2)

startLocalWorkers(n=2, queue="jobs")
ans <- foreach(j=1:2, .combine="c") %dopar% {
  chunk <- sprintf("A%d", j)
  mychunk <- redisGet(chunk)
  sum(mychunk)
}

removeQueue("jobs")
